function getDataUrl(){
	return window.location;
}

function doDOM(json){
	var list=$("#list");
	var size=0;
	$.each(json.sps,function(idx,item){
		size=idx;
		var tr = generate_row(item.name, item.themeName);
		list.append(tr);
	});
	return size;
}

function isFilled(){
	return (($(window).height+300)<$("#list").height);
}

function generate_row(name,theme){
	var tr = $(document.createElement("tr"));
	var td1 = $(document.createElement("td"));
	var td2 = $(document.createElement("td"));
	var td3 = $(document.createElement("td"));
	td1.html(name);
	td2.html(theme);
	td3.html("<a href=\"admin/news/special/edit/"+name+"?TB_iframe=true&height=135&width=260\"" +
			" title=\"添加专题\" class=\"thickbox\">修改</a>\n"+
			"&nbsp;&nbsp;&nbsp;&nbsp;\n"+
			"<a href=\"admin/news/special/edit/"+name+"$?TB_iframe=true&height=135&width=260\"" +
			" title=\"添加专题\" class=\"thickbox\">删除</a>");
	tr.append(td1);
	tr.append(td2);
	tr.append(td3);
	return tr;
}


function refresh_list(newName,themeName){
	var oldName=$(document).data("oldName");
	if($(document).data("type")=="new"){
		var newRow = generate_row(newName, themeName);
		$("#list").append(newRow);
		return;
	}
	$("tr:has(td:contains('"+oldName+"'))").each(function (index, ele) { 
			if($($(ele).children()[0]).html()!=oldName)
				return;
			var newRow = generate_row(newName, themeName);
			$(ele).replaceWith(newRow);
		});
}

function prepare_edit(on,type){
	$(document).data("oldName",on);
	$(document).data("type",type);
}